package com.example.springrestservices.payroll;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: hao
 * @Description:
 * @Date: 2021/10/29 15:58
 * @Version: 1.0
 */

@Configuration
public class LoadDatabase {
    private static final Logger log= LoggerFactory.getLogger(LoadDatabase.class);

    @Bean
    CommandLineRunner initDatabase(EmployeeRepository repository){
        return args -> {
          log.info("Preloading"+repository.save(new Employee("Bilbo Bagging","burglar")));
          log.info("Preloading"+repository.save(new Employee("Frodo Bagging","thief")));
        };
    }
}
